//
//  SiPlugin.m
//  scheme-indent-xcplugin
//
//  Created by Ende on 10/12/29.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "SiPlugin.h"
#import <objc/runtime.h>
#import "SiXCTextView.h"
#import "SiXCTextStorage.h"


@implementation SiPlugin

+ (void)pluginDidLoad:(NSBundle *)bundle {
	
	NSLog(@"Succeed! +pluginDidLoad: %@", bundle);
	//	NSBeep();
	
	Method m1, m2;
	m1 = class_getInstanceMethod([XCTextView class], @selector(indentSelectionIfIndentable:));
	m2 = class_getInstanceMethod([XCTextView class], @selector(__indentSelectionIfIndentable:));
	method_exchangeImplementations(m1, m2);
	//	以下の method_exchange は, .scm ソース編集時に限りインデント設定が変更できるよう使おうとしたが、
	//	期待通りの動作をしなかった。よってコメントアウト。
	/*
	m1 = class_getInstanceMethod([XCTextStorage class], @selector(getUsesTabs));
	m2 = class_getInstanceMethod([XCTextStorage class], @selector(__getUsesTabs));
	method_exchangeImplementations(m1, m2);
	m1 = class_getInstanceMethod([XCTextStorage class], @selector(getIndentWidth));
	m2 = class_getInstanceMethod([XCTextStorage class], @selector(__getIndentWidth));
	method_exchangeImplementations(m1, m2);
	m1 = class_getInstanceMethod([XCTextStorage class], @selector(getTabWidth));
	m2 = class_getInstanceMethod([XCTextStorage class], @selector(__getTabWidth));
	method_exchangeImplementations(m1, m2);
	 */
}

@end
